package com.example.librarysystem.mapper;

import com.example.librarysystem.model.BookInfo;
import com.example.librarysystem.model.PageRequest;
import com.example.librarysystem.model.ResponseResult;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface BookMapper {
//    @Insert("INSERT into book_info (book_name, author, count,price,publish) values " +
//            "(#{bookName},#{author},#{count},#{price},#{publish})" )
//    Integer addBook(BookInfo bookinfo);

    @Select("select * from book_info")
    List<BookInfo> getallbook();
    @Select("select * from book_info where `status`!=0 limit #{offset},#{pageSize}")
    List<BookInfo> getListByPage(PageRequest pageRequest);
    @Select("select count(1) from book_info where `status`!=0")
    Integer count();

    @Insert("insert into book_info (book_name,author,count,price,publish,status) "+
            "values (#{bookName},#{author},#{count},#{price},#{publish},#{status})")
    Integer addBook(BookInfo bookinfo) ;
    @Select("select * from book_info where `status`!=0 and id=#{bookid}")
    BookInfo queryBookById(Integer bookid);


    Integer updateBook(BookInfo bookInfo);
    Integer batchDelete(List<Integer> ids);
}
